package com.jlpay.openapi.demo.trans.b2c;

import com.jlpay.open.jlpay.sdk.java.model.trans.b2c.request.MicroPayRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.b2c.response.MicroPayResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/13
 **/
public class MicroPayService {

    private static final Logger LOGGER = LoggerFactory.getLogger(MicroPayService.class);

    public static void main(String[] args) {
        MicroPayRequest microPayRequest = buildMicropayRequest();
        MicroPayResponse microPayResponse = JlpayOpenApiService.openMerchService()
                .post(microPayRequest, MicroPayResponse.class);
        LOGGER.info("付款码支付(B2C)下单响应:{}", JsonUtils.toString(microPayResponse));
    }

    private static MicroPayRequest buildMicropayRequest() {
        MicroPayRequest microPayRequest = new MicroPayRequest();

        microPayRequest.setMchId("849584358120018");
        microPayRequest.setTermNo("60131234");
        microPayRequest.setPayType("wxpay");
        microPayRequest.setOutTradeNo("ld201911023465529");
        microPayRequest.setPaymentValidTime("10");
        microPayRequest.setBody("充值中心-会员充值");
        microPayRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        microPayRequest.setTotalFee("1");
        microPayRequest.setAuthCode("131208648101095993");
        microPayRequest.setLimitPay("no_credit");
        microPayRequest.setIsHirePurchase("1");
        microPayRequest.setHirePurchaseNum("3");
        microPayRequest.setHirePurchaseSellerPercent("0");
        microPayRequest.setRemark("该订单物流请走顺丰快递");
        microPayRequest.setOpUserId("001");
        microPayRequest.setOpShopId("GD_SZ_001");
        microPayRequest.setDeviceInfo("N50007A8890");
        microPayRequest.setMchCreateIp("123.12.12.123");
        microPayRequest.setLongitude("116.078631");
        microPayRequest.setLatitude("39.71274");
        microPayRequest.setSubAppid("wxid_129752pfasf1671");
        microPayRequest.setGoodsTag("sz001");

        return microPayRequest;
    }
}
